aboutsummaryrefslogtreecommitdiff
path: root/src/app/manga/[title]/page.jsx
blob: 689042b3a4e2dc1909b2dd9187f30f016e080bf6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import styles from "./title.module.css";
import Image from "next/image";
import Link from "next/link";
import { PreFetchMangaInfo } from "../cacher";

export default async function MangaInfo({ params }) {
	const title = params.title;
	const data = await GetSearchedAnime(title);

	PreFetchMangaInfo(data);

	return (
		<div className={styles.Main}>
			<div className={styles.MangaContainer}>
				{title && (
					<div className={styles.SearchedFor}>
						<p>Searched for: {decodeURIComponent(title)}</p>
					</div>
				)}
				{data &&
					data.results.map(async (item, index) => {
						let desc = item.description || ""; // Ensure desc is not null
						if (desc === "") {
							desc = "Not found"; // If desc is empty, set it to "Not found"
						}
						return (
							<Link
								href={`./info/${item.id}`}
								style={{ textDecoration: "none" }}
								key={index}
							>
								<div className={styles.MangaEntries}>
									<Image
										src={`https://sup-proxy.zephex0-f6c.workers.dev/api-content?url=${item.image}`}
										width={180}
										height={270}
										alt="Manga Poster"
									/>
									<div className={styles.MangaInfo}>
										<p className={styles.MangaTitle}>
											{item.title["english"] ||
												item.title["romaji"]}
										</p>
										<p className={styles.MangaDescription}>
											{desc.includes &&
											desc.includes("<br")
												? desc.split("<b")[0]
												: desc}
										</p>
										<p className={styles.MangaStatus}>
											Status: {item.status || "not sure"}
										</p>
										<p className={styles.MangaChapters}>
											Chapters:{" "}
											{item.totalChapters || "not sure"}
										</p>
										<p className={styles.MangaVolume}>
											Volumes:{" "}
											{item.volumes || "not sure"}
										</p>
									</div>
								</div>
							</Link>
						);
					})}
			</div>
		</div>
	);
}

async function GetSearchedAnime(title) {
	const res = await fetch(
		"https://consumet-jade.vercel.app/meta/anilist-manga/" + title
	);
	const data = await res.json();
	return data;
}